package com.lmn.shardingsphere.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lmn.shardingsphere.dao.entity.TestOrder;
import com.lmn.shardingsphere.dao.mapper.TestOrderMapper;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 服务实现类
 * </p>
 */
@Repository
public class TestOrderDAO extends BaseDAO<TestOrderMapper, TestOrder> {

    public void query(int pageNum, int pageSize, TestOrder test) {
        LambdaQueryWrapper<TestOrder> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(null != test.getOrderId(), TestOrder::getOrderId, test.getOrderId())
                .orderBy(true, false, TestOrder::getCreateTime);
        IPage<TestOrder> page = mapper.selectPage(new Page<>(pageNum, pageSize), wrapper);
        System.out.println("记录数：" + page.getTotal());
        System.out.println("记录数：" + page.getRecords().toString());
    }

}
